home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / mimelib / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-05-14  |  6.8 KB  |  174 lines

  1. //=============================================================================
  2. // File:       param.h
  3. // Contents:   Declarations for DwParameter
  4. // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
  5. // WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
  6. //
  7. // Copyright (c) 1996, 1997 Douglas W. Sauder
  8. // All rights reserved.
  9. //
  10. // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
  11. // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  12. // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
  13. // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. //
  15. // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  16. // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  17. // PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
  18. // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  19. // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. //
  21. //=============================================================================
  22.  
  23. #ifndef DW_PARAM_H
  24. #define DW_PARAM_H
  25.  
  26. #ifndef DW_CONFIG_H
  27. #include <mimelib/config.h>
  28. #endif
  29.  
  30. #ifndef DW_STRING_H
  31. #include <mimelib/string.h>
  32. #endif
  33.  
  34. #ifndef DW_MSGCMP_H
  35. #include <mimelib/msgcmp.h>
  36. #endif
  37.  
  38.  
  39. //=============================================================================
  40. //+ Name DwParameter -- Class representing a MIME field body parameter
  41. //+ Description
  42. //. {\tt DwParameter} represents the {\it parameter} component of the
  43. //. Content-Type header field as described in RFC-2045.  A parameter
  44. //. consists of an attribute/value pair.  {\tt DwParameter} has member
  45. //. functions for getting or setting a parameter's attribute and value.
  46. //.
  47. //. A {\tt DwParameter} object may be included in a list of {\tt DwParameter}
  48. //. objects.  You can get the next {\tt DwParameter} object in the list by
  49. //. calling the member function {\tt Next()}.
  50. //=============================================================================
  51. // Last modified 1997-08-13
  52. //+ Noentry ~DwParameter _PrintDebugInfo
  53.  
  54. class DW_EXPORT DwParameter : public DwMessageComponent {
  55.  
  56.     friend class DwMediaType;
  57.  
  58. public:
  59.  
  60.     DwParameter();
  61.     DwParameter(const DwParameter& aParam);
  62.     DwParameter(const DwString& aStr, DwMessageComponent* aParent=0);
  63.     //. The first constructor is the default constructor, which sets the
  64.     //. {\tt DwParameter} object's string representation to the empty string
  65.     //. and sets its parent to NULL.
  66.     //.
  67.     //. The second constructor is the copy constructor, which copies the
  68.     //. string representation, attribute, and value from {\tt aParam}.
  69.     //. The parent of the new {\tt DwParameter} object is set to NULL.
  70.     //.
  71.     //. The third constructor copies {\tt aStr} to the {\tt DwParameter}
  72.     //. object's string representation and sets {\tt aParent} as its parent.
  73.     //. The virtual member function {\tt Parse()} should be called immediately
  74.     //. after this constructor in order to parse the string representation.
  75.     //. Unless it is NULL, {\tt aParent} should point to an object of a class
  76.     //. derived from {\tt DwMediaType}.
  77.  
  78.     virtual ~DwParameter();
  79.  
  80.     const DwParameter& operator = (const DwParameter& aParam);
  81.     //. This is the assignment operator.
  82.  
  83.     virtual void Parse();
  84.     //. This virtual function, inherited from {\tt DwMessageComponent},
  85.     //. executes the parse method for {\tt DwParameter} objects.
  86.     //. It should be called immediately after the string representation
  87.     //. is modified and before the parts of the broken-down
  88.     //. representation are accessed.
  89.  
  90.     virtual void Assemble();
  91.     //. This virtual function, inherited from {\tt DwMessageComponent},
  92.     //. executes the assemble method for {\tt DwParameter} objects.
  93.     //. It should be called whenever one of the object's attributes
  94.     //. is changed in order to assemble the string representation from
  95.     //. its broken-down representation.  It will be called
  96.     //. automatically for this object by the parent object's
  97.     //. {\tt Assemble()} member function if the is-modified flag is set.
  98.  
  99.     virtual DwMessageComponent* Clone() const;
  100.     //. This virtual function, inherited from {\tt DwMessageComponent},
  101.     //. creates a new {\tt DwParameter} on the free store that has the same
  102.     //. value as this {\tt DwParameter} object.  The basic idea is that of
  103.     //. a ``virtual copy constructor.''
  104.  
  105.     const DwString& Attribute() const;
  106.     //. Returns the attribute contained by this parameter.
  107.  
  108.     void SetAttribute(const DwString& aAttribute);
  109.     //. Sets the attribute contained by this parameter.
  110.  
  111.     const DwString& Value() const;
  112.     //. Returns the value contained by this parameter.
  113.  
  114.     void SetValue(const DwString& aValue, bool forceNoQuotes=false);
  115.     //. Sets the value contained by this parameter.
  116.  
  117.     DwParameter* Next() const ;
  118.     //. Returns the next {\tt DwParameter} object in the list.
  119.  
  120.     void SetNext(DwParameter* aParam);
  121.     //. Returns the next {\tt DwParameter} object in the list.  Since
  122.     //. {\tt DwMediaType} has member functions for adding {\tt DwParameter}
  123.     //. objects to its list, you should avoid using this function.
  124.  
  125.     static DwParameter* NewParameter(const DwString& aStr,
  126.         DwMessageComponent* aParent);
  127.     //. Creates a new {\tt DwParameter} object on the free store.
  128.     //. If the static data member {\tt sNewParameter} is NULL,
  129.     //. this member function will create a new {\tt DwParameter}
  130.     //. and return it.  Otherwise, {\tt NewParameter()} will call
  131.     //. the user-supplied function pointed to by {\tt sNewParameter},
  132.     //. which is assumed to return an object from a class derived from
  133.     //. {\tt DwParameter}, and return that object.
  134.  
  135.     //+ Var sNewParameter
  136.     static DwParameter* (*sNewParameter)(const DwString&, DwMessageComponent*);
  137.     //. If {\tt sNewParameter} is not NULL, it is assumed to point to a
  138.     //. user-supplied function that returns an object from a class derived from
  139.     //. {\tt DwParameter}.
  140.  
  141. private:
  142.  
  143.     DwString mAttribute;
  144.     DwString mValue;
  145.     bool     mForceNoQuotes;
  146.     DwParameter* mNext;
  147.     static const char* const sClassName;
  148.  
  149. public:
  150.  
  151.     virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
  152.     //. This virtual function, inherited from {\tt DwMessageComponent},
  153.     //. prints debugging information about this object to {\tt aStrm}.
  154.     //. It will also call {\tt PrintDebugInfo()} for any of its child
  155.     //. components down to a level of {\tt aDepth}.
  156.     //.
  157.     //. This member function is available only in the debug version of
  158.     //. the library.
  159.  
  160.     virtual void CheckInvariants() const;
  161.     //. Aborts if one of the invariants of the object fails.  Use this
  162.     //. member function to track down bugs.
  163.     //.
  164.     //. This member function is available only in the debug version of
  165.     //. the library.
  166.  
  167. protected:
  168.  
  169.     void _PrintDebugInfo(std::ostream& aStrm) const;
  170.  
  171. };
  172.  
  173. #endif
  174.